package com.example.module_home.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.example.lib_common.view.entity.NoticeEntity
import com.example.module_home.databinding.NoticItemLayoutBinding

class NoticeListAdapter(private val data: MutableList<NoticeEntity>):RecyclerView.Adapter<NoticeListAdapter.NoticeItemViewHolder>() {
    inner  class  NoticeItemViewHolder(val itemDataBinding:NoticItemLayoutBinding):RecyclerView.ViewHolder(itemDataBinding.root)

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NoticeItemViewHolder {
        return NoticeItemViewHolder(NoticItemLayoutBinding.inflate(LayoutInflater.from(parent.context),parent,false))
    }

    override fun getItemCount(): Int {
        return data.size
    }

    override fun onBindViewHolder(holder: NoticeItemViewHolder, position: Int) {
        val noticeEntity = data[position]
        holder.itemDataBinding.run {
            entity = noticeEntity
            executePendingBindings()
        }
    }

}